package com.springboot.strategy.demo002;

/**
 * 策略上下文
 */
public class StrategyContext {

    public void contextMethod(String strategyCode){
//        IStrategy strategy = StrategyFactory.getStrategy(strategyCode);
        IStrategy strategy = StrategySingleton.getInstance().getStrategy(strategyCode);
        if(strategy != null){
            // 调用策略实现的方法
            strategy.strategyMethod();
        }
    }
}
